<%@ page language="java" contentType="text/html" pageEncoding="utf-8"%>
<%@include file="/WEB-INF/pages/common/common.jsp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head> 
    <%@include file="/WEB-INF/pages/common/head.jsp"%>
    <%@include file="/resources/datepicker/datepicker.jsp"%>
    <title><spring:message code="title.ipic.target"/></title>
      <style type="text/css">
        .font_stress{
            color: red;font-size: 13px;font-weight:bold;
        }
    </style>
    <script type="text/javascript">
           var operateDialog;
          var datagrid;
	        $(function() {
	            datagrid=$('#datagrid').datagrid({
	                onClickRow:function(rowIndex){
	                    var rows = datagrid.datagrid('getRows');
	                    for ( var i = 0; i < rows.length; i++) {
	                        datagrid.datagrid('endEdit', i);
	                    }
	                    datagrid.datagrid('beginEdit', rowIndex);
	                }
	            }); 
	        });
	        
	       function save_(){
	       var objName= document.getElementById("chk_updateRequireds");
	        var values= $('#values').numberbox('getValue'); 
	        if(values==''){
	        		 $.messager.alert('<spring:message code='msg.tip'/>','得分不能为空!');
		            return;
	        }
	        
	        var comments=$('#comments').val(); 
	        
	        var value = $("input[name='xx'][type='radio']:checked").val();
	        if(value==1){
		        var v1 =$('#certificationDate1').val();
		        var v2 =$('#expireDate').val();  
		       if(v1==''){
		            $.messager.alert('<spring:message code='msg.tip'/>','认证日期不能为空!');
		            return;
		       }
		       if(v2==''){
		          $.messager.alert('<spring:message code='msg.tip'/>','到期日期不能为空!');
		          return;
		       }
		       
		       if(objName.checked){
     	          $('#updateRequired').val("1");
		       }else{
		          $('#updateRequired').val("0");
		       }
			     $('#certificationType').val(value);
			     $('#certificationDate').val(v1);
			     $('#expiredDate').val(v2);  
	        }else{
	          	$('#certificationType').val(value);
	             $('#updateRequired').val("");
			     $('#certificationDate').val("");
			     $('#expiredDate').val("");  
	        }
	        $('#comment').val(comments); 
			$('#value').val(values); 
	      
	        var isV =$("#tableForm").form("validate");
            if(!isV) return; 
            
            imonJYRH.showZone();
            var effectData = new Object();
            effectData["envManage"] =  JSON.stringify(imonJYRH.serializeObject($("#tableForm *")));
            
            $.ajax({
                url : '${path}/business/supplier_quality/env_manage/ajaxModify.do',
                 data : effectData,
                 cache : false,
                 async : true,
                 dataType : "json",
                success : function(reMsg) {
                    if(reMsg.success){
                        parent.returnResult();
                        message.show({ msg : reMsg.msg,title : '<spring:message code='msg.tip'/>',showType:'slide'});
                    }else{
                        if(!imonJYRH.isBlank(reMsg.obj)){
                            $.messager.alert('<spring:message code='msg.tip'/>',reMsg['obj']);
                        }else{
                            $.messager.alert('<spring:message code='msg.tip'/>',reMsg['msg']);
                        }
                    }
                    imonJYRH.hideZone();
                }
            });
        }
      function envValue(values){
          if(values==1){
             $('#values').numberbox('setValue',0);
          }
          else if(values==2){
          	 $('#certificationDate1').val(null);
		     $('#expireDate').val(null);  
             $('#values').numberbox('setValue',-2);
          }else{
             $('#certificationDate1').val(null);
		     $('#expireDate').val(null);    
            $('#values').numberbox('setValue',-5);
          }
       }
      function dialogSupplier_(){
            var href = '${path}/basedata/supplier/dialogUI.do';
            operateDialog = $("#operateDialog").dialog({
                title : '<spring:message code='msg.dialog.choose'/>',
                width : 650,
                height : 400
            });
            $("#operateIFrame")[0].src=href;
            operateDialog.dialog('open');
        }
     function dialogSupplierReturn(row){
            $("#supplierId").val(row['id']);
            $("#supplierCode").val(row['code']);
            $("#supplierName").val(row['name']);
            operateDialog.dialog('close');
        }
    </script>
</head>
<body class="easyui-layout">
<form >
<div data-options="region:'center'">
    <div class="datagrid-toolbar" style="height:480px">
        <table width="100%" id="tableForm">
                <tr>
                    <td align="right">SupplierCode供应商编码：</td>
                    <td>
                        <input type="hidden" id='supplierId' name="supplierId" value="${envManageVo.supplierId}"/>
                        <input type="text" id="supplierCode" onclick="dialogSupplier_();" readonly="true" value="${envManageVo.supplierCode}" disabled/>
                    </td>
                    <td align="right">SupplierName供应商名称：</td>
                    <td>
                        <input type="text" id="supplierName" style="width: 180px;" disabled value="${envManageVo.supplierName}"/>
                    </td>
                   <!-- <td align="right">Supplier Type供应商类型：</td>
                    <td>
                        <input type="text"  name="type" disabled/>
                    </td>-->
                     <input type="hidden"  name="certificationType" id="certificationType" value="${envManageVo.certificationType}"/>
                     <input type="hidden"  name="certificationDates" id="certificationDate" value="${envManageVo.certificationDates}"/>
                     <input type="hidden"  name="expiredDates" id="expiredDate" value="${envManageVo.expiredDates}"/>
                     <input type="hidden"  name="updateRequired" id="updateRequired" value="${envManageVo.updateRequired}"/>
                     <input type="hidden"  name="value" id="value" value="${envManageVo.value}"/>
                     <input type="hidden"  name="comment" id="comment" value="${envManageVo.comment}"/>
                     <input type="hidden"  name="id" id="id" value="${envManageVo.id}"/>
                </tr>
            </table>

        <br/>
        <div class="font_stress" align="center">
            Environmental Management System(EMS)
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            Evaluation Value：
            <input type="text" id="values" class="easyui-numberbox" data-options="required:true" value="${envManageVo.value}" readonly="true"/>
           
        </div>
        <br/>
        <hr width="800px"/>
        <table width="100%">
            <tr>
                <td align="right" width="400px"></td>
                <td></td>
                <td><label style="font-weight:bold;">Certification Date</label></td>
            </tr>
            <tr>
                <td align="right">
                    <label for="radio_1">ISO 14001 or EMAS认证</label>
                </td>
                <td>
                    <input type="radio" style="width: 10px;"  name="xx" id="radio_1" value="1" onclick="envValue(1)"
                    <c:if test="${envManageVo.certificationType==1}">
                    		checked=true
                    </c:if>
                    >
                </td>
                <td>
                    <input type="text"  id="certificationDate1" value="${envManageVo.certificationDates}" onFocus="WdatePicker({isShowClear:false,isShowToday:false,readOnly:true})" class="field Wdate"/>
                </td>
                 <td align="right">Expire Date：</td>
                <td>
                    <input type="text"   id="expireDate" value="${envManageVo.expiredDates}" onFocus="WdatePicker({isShowClear:false,isShowToday:false,readOnly:true})" class="field Wdate"/>
                </td>
                  <td align="right">
                    <label for="chk_updateRequired">Update Required</label>
                    <input id="chk_updateRequireds" type="checkbox" style="width: 10px;" name="chk_updateRequireds"  
                     <c:if test="${envManageVo.updateRequired==1}">
                    		checked=true
                    </c:if>/>
                </td>
            </tr>
            <tr>
                <td align="right">
                    <label for="radio_3">没有ISO 14001 or EMAS 的环境体系认证<br/>但是有证据计划两年内完成<br/>
                        Environmental certifications:<br/> ISO 14001 or EMAS not available<br/> but introduction within 2 years demonstrably planned</label>
                </td>
                <td>
                    <input type="radio" style="width: 10px;" name="xx" id="radio_3" onclick="envValue(2)" value="2"   
                    <c:if test="${envManageVo.certificationType==2}">
                    		checked=true
                    </c:if>
                    >
                </td>
            </tr>
            <tr>
                <td align="right">
                    <label for="radio_2">
                        没有ISO 14001 or EMAS 的环境体系认证，<br/>也没有证据计划两年内完成，必须针对此体系要求自审<br/>
                        Environmental certifications: <br/>ISO 14001 or EMAS not available <br/>and not scheduled for introduction within 2 years, self audit necessary
                    </label>
                </td>
                <td>
                    <input type="radio" style="width: 10px;" name="xx" id="radio_2"  onclick="envValue(3)" value="3"
                     <c:if test="${envManageVo.certificationType==3}">
                    		checked=true
                    </c:if>
                    >
                </td>
                <td>
                </td>
            </tr>
            <!--<tr>
                <td align="right">
                    <label for="radio_3">Certification NOT plannified</label>
                </td>
                <td>
                    <input type="radio" style="width: 10px;" name="xx" id="radio_3">
                </td>
                <td>
                    <input type="text" class="easyui-datebox"/>
                </td>
            </tr>-->
        </table>
        <br />
        <hr width="800px"/>
        <table width="100%">
            <tr>
                <td width="200px"></td>
                <td align="right">
                    Comment评论：
                </td>
                <td>
                    <textarea rows="3" cols="40" id="comments" >${envManageVo.comment}</textarea>
                </td>
            </tr>
        </table>
        <br />
        <div align="right">
               <a class="easyui-linkbutton" href="javascript:void(0);" iconCls="icon-save" onclick="save_();"><spring:message code='button.save'/></a>
            <a class="easyui-linkbutton" href="javascript:void(0);" iconCls="icon-no" onclick="parent.operateDialog.dialog('close');"><spring:message code='button.close'/></a>
        </div>
    </div>
</div>
</form> 
	<div id="operateDialog" class="easyui-dialog"
		style="width:880px;height:520px;"
		data-options="iconCls:'icon-save',resizable:true,modal:true,closed: true,collapsible:true,maximizable:true">
		<iframe scrolling="auto" id='operateIFrame' frameborder="0" src=""
			style="width:100%;height:100%;" />
	</div>
</body>
</html>